//
//  WEBViewController.m
//  BLDMusics
//
//  Created by 白云杰 on 16/3/17.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "WEBViewController.h"

@interface WEBViewController ()<UIWebViewDelegate>

@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) UIView *view1;
@property (nonatomic, strong) UIActivityIndicatorView *activityIV;

@end

@implementation WEBViewController

- (void)dealloc {
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initWebView];
}

- (void)initVIew {
    self.view1 = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view1.backgroundColor = [UIColor clearColor];
    self.view1.alpha = 0.5;
    [self.view addSubview:self.view1];

    
    self.activityIV = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    self.activityIV.center = self.view1.center;
    [self.view1 addSubview:self.activityIV];
    
}

- (void)initWebView {
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH - 64)];
    [self.view addSubview:_webView];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_url]]];
    self.webView.delegate = self;
}

#pragma mark - webview的代理方法
- (void)webViewDidStartLoad:(UIWebView *)webView {
    //NSLog(@"开始加载");
    [self initVIew];
    [self.activityIV startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    //NSLog(@"完成加载");
    [self.view1 removeFromSuperview];
    [self.activityIV stopAnimating];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    //NSLog(@"加载出错");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
